package org.linlinjava.litemall.admin.web;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallQualification;
import org.linlinjava.litemall.db.service.LitemallQualificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/qualify")
public class AdminQualificationController {
    @Autowired
    private LitemallQualificationService qualificationService;
    @RequiresPermissions("admin:qualify:list")
    @GetMapping("/list")
    public Object list(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "100") Integer limit) {
        List<LitemallQualification> list = qualificationService.querySelective( page, limit);
        return ResponseUtil.okList(list);
    }
    @RequiresPermissions("admin:qualify:delete")
    @PostMapping("/delete")
    public Object delete(@RequestParam Integer id) {
        qualificationService.deleteById(id);
        return ResponseUtil.ok();
    }
    @RequiresPermissions("admin:qualify:add")
    @PostMapping("/add")
    public Object add(@RequestBody LitemallQualification qualification) {
        qualificationService.add(qualification);
        return ResponseUtil.ok();
    }
    @RequiresPermissions("admin:qualify:update")
    @PostMapping("/update")
    public Object update(@RequestBody LitemallQualification qualification) {
        qualificationService.updateById(qualification);
        return ResponseUtil.ok();
    }

}
